package com.gaofei.config;



import org.springframework.beans.factory.annotation.Value;

import java.io.FileWriter;
import java.io.IOException;

/* *
 *类名：AlipayConfig
 *功能：基础配置类
 *详细：设置帐户有关信息及返回路径
 *修改日期：2017-04-05
 *说明：
 *以下代码只是为了方便商户测试而提供的样例代码，商户可以根据自己网站的需要，按照技术文档编写,并非一定要使用该代码。
 *该代码仅供学习和研究支付宝接口使用，只是提供一个参考。
 */
public class AlipayConfig {

//↓↓↓↓↓↓↓↓↓↓请在这里配置您的基本信息↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    @Value("${alipay.app_id}")
    public static String app_id;

    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key = "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCspZuyimkZ0hG441eITVVQyeCfwV9BgTpDocDC7IG85gHqDFiORIsKyDKPH7O0GFAHFH4bE99o8vSfTsMFPqVmQ2Y2YgkR80wCkWkJ8GNA0CNF+CscxcasmFtIfJR5Dcoheu3zK9Ej7HzqndDNKKTV896AG+PtutO7tQhyEA16jT1fMGxy6mss8jh0N6jwHr2OtA7f8rlSM//nJmRLEJmw/ezPAkYXXH4HUS0CvrJUnnKMniM81t6129yTZI3jr3RHPhc8B5YRGV/HSebfJz3jZ83qzqBnniRj7KHI1inaIzDb3b4WHlxHTj/pXpf2qi7KYu82eUQ4kOhFDO4sizeBAgMBAAECggEARLYokFdb2wXrPb1lYf79PIkMGCja43QuHyqqUCnWvLqB+odtWznWaLUiwimo2L1wZFD4m4g+O0OurhSns1eqdlfOv0gnOfitwLvkpSsCJZJw53EMn4frOVftxJyobsFZOBf3yfcfZn/Be5LRvkU1zV0gqbXv8faQPD2hndvbsXEJMRPKyOoqSDpPtC5ncpGrnP/NLfaor3PfHgQEz8MZJqWe9gCrunmJCYfJeC5xvVzLOOBdZm8qlqNINkzVYIQ6tK9Bfna7mVVdmX3ERsW0VHap1Cg6gG8Ve/Nq9zkodA5jMXCqQGBY6xXBOv0hdcYCPwbwqnbGN3Jn8W4YZLndQQKBgQD5plS4L2XOLA0H4lTX9dIwFaX+LFxu4wrjIiHMydsVBDRueNiPEPEnAqNQiBcXLhFPa2mze0DlwXMZ7YsmNjqSyQdpzRWGRzfrNxvx+qXf9NeOXgiVCw6EYAv/T+zLuw+p27QgPKnXELqJiB981dMEHGhMQ205Kpn0WzfgwHVnyQKBgQCxCdmsgMrdqOFDtDUWegwva7Fh0sU1hIqoA3pmnAOj43o+HzQcidFKkAgeTDEzaOn1x1WlrkjJ2vXtq5mrs15zp/xgLIG9gB9ltvvVqBNfB41UkzOmXEzTgNxCEJk0EBIrotq85zMpG04Irf6v1+lpiw5bheHcufaa/iODi5ud+QKBgQCY48yuoBhxE3lHgs0DFYEMAbYO24wgPNvGDnk0ucp6LIEPxuKZe360rWDnSPEbORNQ2C97w9gS3U5oapn1ZPCqRINNwFOWULdmTfHHWAGODpyUi/IllQfm+gte6MvUWVNWaz79HynElHIpGDxwb2Mz+VHGouSZRgXTKKon8rX0QQKBgQCe+46Ld/k1xyPL7ffCoIVyzE4139YTclwl90GjBbXLJkuvn8vnWOgnAmMX+iow1aVMft5t864P/17cOT69z00hpZhhMXatG3KWoBVVUCNdMmX7rlkyqy6evNiPR2KdO1Vl9FBkVWc/IfMYnk/Zz5Yfnq2dCQTEeAd6NoDj76om2QKBgH0VC3I9Nf1BJ8StoLsLi7lCoWfORPH519KqLt7tGv6yHb/bnwIoDKwbfkQCnnBOwC+ADuPyhgVVqGqmUuersyFdTXLp1G0+9xXQNyh6iTYaAmwUZr3XEP/EJIlXgRAg9P/hHok19nWLoUpikY8oRGY8JtOIwgQ5/TqLIA46Zsga";

    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAio0KicEvQ/8404EWznkT1MCvomH3iVIYnrHRVXtL3xFXfRBxRBe5GTzbDLhayz1g+a/nYShUDaSYRcpdeqr9koQTwg8946JB5wC/SFcMFQdxdu4lyR+ZiyGI9bRgevZKqYyyc4n6nb0xLghpgPIcaQOwFLHRkiFh0jQwcTX0uuF4YTvxiYTFQk1oQKU1elfemhF4bqAq/K1xPhAtNxMPxH9HokGMklyf9a3e8gPtBy1dOv7g0yB7V5HuUR+88MgCUYjaN9Hx1LtMeP0I8YAOMSxQ4xBKOG3GPzy6rkvr68gdt1y25qKaqJWDJMSpzgbjFy2tltJGUEGx+rsA0ZWjkwIDAQAB";

    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问,这个常用+主动查询账单
    public static String notify_url = "";

    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问
    public static String return_url = "http://127.0.0.1:8080/notify";

    // 签名方式
    public static String sign_type = "RSA2";

    // 字符编码格式
    public static String charset = "utf-8";

    // 支付宝网关
//	public static String gatewayUrl = "https://openapi.alipay.com/gateway.do";
    public static String gatewayUrl = "https://openapi-sandbox.dl.alipaydev.com/gateway.do";

    // 支付宝网关
    public static String log_path = "D:\\";


//↑↑↑↑↑↑↑↑↑↑请在这里配置您的基本信息↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑

    /**
     * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）
     * @param sWord 要写入日志里的文本内容
     */
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}